<?php
// +----------------------------------------------------------------------
// | CLTPHP.Pro [广告模型]
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2029 https://www.cltphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://www.cltphp.com/detail-140.html )
// +----------------------------------------------------------------------
// | Author: chichu <1109305987@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\model;
class Ad extends Base
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    //protected $validate = 'Ad';
    // 一对一获取所属分组
    public function adsense()
    {
        return $this->belongsTo('Adsense', 'as_id','id');
    }
    // 获取字段列表
    public static function getList($where = array(), $page, $order = ['sort', 'create_time'=>'desc']){
        $list = self::where($where)->order($order)->paginate($page);
        foreach ($list as $k=>$v){
            $v['as_title'] = $v->adsense->getData('title');
        }
        return $list;
    }

}